package com.weiyi.weiman.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @Author zhang
 * @Date 2021/5/14 上午11:26
 * @Description
 * @Version 1.0
 **/
public class HttpContextUtil {

    private HttpContextUtil() {

    }

    //获取HttpServletRequest请求
    public static HttpServletRequest getHttpServletRequest() {
        return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
    }

}